﻿using Cngot.Extensions.EventBus.RabbitMQ.Integration;
using Microsoft.Extensions.Options;
using System;

namespace Cngot.Extensions.EventBus.RabbitMQ
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
    public class MessageSubscribeAttribute : Attribute
    {
        internal string Queue;
        internal string Instance;
        internal bool EnableAutoCommit;
        internal RabbitExchangeType Type;
        internal string Route;
        public MessageSubscribeAttribute(string routingKey, string queue, RabbitExchangeType type = RabbitExchangeType.Direct, string instance = null, bool enableAutoCommit = false)
        {
            this.Route = routingKey;
            this.Queue = queue;
            this.Type = type;
            this.Instance = instance ?? Options.DefaultName;
            this.EnableAutoCommit = enableAutoCommit;
        }
    }
}
